<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>新建渠道二维码</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/cusmanage/css/formSelects-v4.css">
    <link rel="stylesheet" href="/fission/css/iconfont.css">
	<style type="text/css">
		body{
			background: #e9e9e9; 
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
			justify-content: space-between;
		}
		.public_title_container a{
			fill: #999;
		}
		/*公共表单部分*/
		.public_form_container{
			padding: 20px 20px 40px 20px;
		}
		.public_form_content{
			padding: 24px 40px 24px 0;
			background: #fff;
			border: 1px solid #e9e9e9;
			margin-bottom: 8px;
		}
		.public_form_List{
			margin-bottom: 10px;
		}
		.public_form_List:last-child{
			margin-bottom: 0px;
		}
		.public_formTitle_container lable{
			font-size: 13px;
			font-weight: bold;
		}
		/*新加的二维码*/
		.uploadQrcode_container{
			display: flex;
			align-items: center;
		}
		.uploadQrcode_container button{
			margin-left: 15px;
		}
		.uploadQrcode_container span{
			color: #999;
			font-size: 13px;
		}
		.uploadQrcode_content{
			position: relative;
			width: 150px;
			height: 150px;
			overflow: hidden;
		}
		.qrcodeImg_h{
			width: 150px;
			height: 150px;
		}
		.qrcodeHead_h{
			width: 35px;
			height: 35px;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
		}
		.service-card {
		  padding: 0 7px;
		  color: rgba(0,0,0,.65);
		  line-height: 28px;
		  font-size: 13px;
		  display: inline-block;
		  margin: 0 8px 0 5px;
		  -webkit-box-sizing: border-box;
		  box-sizing: border-box;
		  white-space: nowrap;
		  background: #fafafa;
		  border: 1px solid #e9e9e9;
		  border-radius: 4px;
		  position: relative;
		}
		.service-card i {
		  font-size: 14px;
		  display: inline-block;
		  color: #7da3d1;
		  margin-right: 2px;
		}
		.service-card .close {
		  position: absolute;
		  top: -13px;
		  right: -8px;
		  opacity: .6;
		  cursor: pointer;
		}
		.service-card .close:hover {
		  opacity: 1;
		}
	</style>
</head>
<body>
	<form class="layui-form" id="form1">
		

		<div class="public_container">
			<!-- /*公共头部带搜索*/ -->
			<div class="public_content">
				<div class="public_title_container">
					<p>新建渠道二维码</p>
					<a href="javascript:history.back(-1)">
						<svg t="1599462684269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8055" width="20" height="20"><path d="M501.2992 273.408l1.024-156.16L184.65792 379.904l314.29632 266.1376 0.95232-149.2992c313.86624 42.5984 178.29888 231.3216-0.5632 410.2144 619.5712-404.3776 251.01312-590.6432 1.95584-633.5488z" p-id="8056"></path></svg>
					</a>
				</div>

			</div>
			<!-- /*公共头部带搜索*/ end -->
			<!-- 公共表单部分 -->
			<div class="public_form_container">
				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">渠道名称：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="name" required  lay-verify="required" placeholder="请输入渠道名称，限10字符以内" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">自动验证：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block" id="verification">
								<input type="radio" lay-filter="verification"  name="skip_verify" value="1" title="是" checked>
								<input type="radio" lay-filter="verification"  name="skip_verify" value="0" title="否">
							</div>
						</div>
					</div>
					<div class="public_form_List" id="verificationContainer" >
						<div class="public_formTitle_container">
							<lable class="layui-form-label">使用人员：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<span class="layui-btn layui-btn-primary" id="addPeople">+ 前往添加</span>
							</div>
							<div class="flex align-start" style="padding: 6px 5px 0px 105px;" id="checkUserCon">
							</div>
						</div>
						<input type="hidden" name="checkUser" id="checkUser"/>
					</div>
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">备注：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<input type="text" name="bz"  placeholder="请输入备注，限20字符" autocomplete="off" class="layui-input">
							</div>
						</div>
					</div>
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">二维码预览：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block uploadQrcode_container">
								<div class="uploadQrcode_content">
									<img class="qrcodeImg_h" src="http://weidogstest.oss-cn-beijing.aliyuncs.com/884b64115b0a7d0296d7025b190d27a6.png" alt="">
									<img class="layui-upload-img qrcodeHead_h" src="http://weidogstest.oss-cn-beijing.aliyuncs.com/3d3847efa9603079ec88524c7eeaff4a.jpg" id="demo1">
									<input type="hidden" name="img" id="imghiden">
                                    <input type="file" hidden id="filkes"/>
								</div>
							  	<button type="button" class="layui-btn" onclick="falses()" id="test1">上传图片</button>
							  	
							    <p id="demoText"></p> 
							</div>
							<div class="layui-input-block uploadQrcode_container">
								<span>此二维码只是预览效果，请勿直接使用~</span>
							</div>
						</div>
					</div>
				</div>
				<!-- 点大商城 -->
				{if $pb_exist} 
				<div class="public_form_content">
					<div class="layui-form-item">
					    <label class="layui-form-label">发放优惠券</label>
					    <div class="layui-input-block">
					      <input type="checkbox" name="pb_coupon_status" lay-skin="switch" lay-filter="pb_coupon">
					    </div>
					</div>
					<div class="layui-form-item pb_coupon" style="display: none;">
						<label class="layui-form-label"> </label>
						<div class="layui-inline">
							<div class="layui-input-inline">
						      <select name="pb_coupon_id">
						        {loop $pbCoupons as $coupon}
						        <option value="{$coupon['id']}">{$coupon['name']}</option>
						        {/loop}
						      </select>
						    </div>
						    <div class="layui-input-inline">
						    	<input type="number" name="pb_coupon_num" min=0 autocomplete="off" class="layui-input" placeholder="请输入数量">
						    </div>
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">会员等级</label>
					    <div class="layui-input-block">
					      <input type="checkbox" name="pb_setlevel_status" lay-skin="switch" lay-filter="pb_setlevel">
					    </div>
					</div>
					<div class="layui-form-item pb_setlevel" style="display: none;">
						<label class="layui-form-label"> </label>
						<div class="layui-input-inline">
					      <select name="pb_setlevel_id">
					        {loop $pbLevels as $level}
					        <option value="{$level['id']}">{$level['name']}--{$level['discount']/1 == 10 ? '无折扣' : ($level['discount']/1).'折'}</option>
					        {/loop}
					      </select>
					    </div>
					</div>
				</div>
				{/if}

				<div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">自动打标签：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block" id="autoLable">
							  <input type="checkbox" lay-filter="autoLable" name="auto_label" lay-skin="switch" checked>
							</div>
						</div>
					</div>
					<div class="public_form_List" id="autoLableContainer">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">选择标签：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<span class="layui-btn layui-btn-primary" id="addLable">+ 添加标签</span>
							</div>
							<div class="flex align-start" style="padding: 6px 5px 0px 105px;" id="checkLableCon">
							</div>
						</div>
						<input type="hidden" name="checkLable" id="checkLable"/>
					</div>
				</div>

		<!-- 分时段欢迎语 html start -->
        <div class="public_form_content">
					<div class="public_form_List">
						<div class="public_formTitle_container">
							<lable class="layui-form-label" style="padding:9px 0;width:110px">分时段欢迎语：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
							  <input type="checkbox" lay-filter="partTimeWelcome" id="partTimeWelcome" name="part_time_welcome_msg" lay-skin="switch">
							</div>
						</div>
					</div>
					<!-- 时段list -->
					<div class="part-time-list" style="display: none;">
						<!-- 必须 至少有一个 part-time-item，用作添加时的模板。编辑的时候有则带数据循环渲染出来，无则 和首次创建一样渲染个空的 -->
						<div class="public_form_List part-time-item" style="position: relative;">
							<div class="public_formTitle_container">
								<lable class="layui-form-label part-time-item-index">时段1：</lable>
							</div>
							<!-- 删除按钮 -->
							<div class="part-time-item-del" style="position: absolute;z-index: 9;right: -37px;bottom: 0;">
								<button type="button" class="layui-btn layui-btn-sm layui-btn-primary">
									<i class="layui-icon">&#xe640;</i>
								</button>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block" style="padding:10px 20px;background:#fdfdfd;border:1px solid #e5e5e5;">

									<div class="public_formTitle_container">
										<lable class="layui-form-label" style="float: none;text-align: left;padding-left: 0;">发送日期：</lable>
									</div>
									<div class="layui-input-inline" style="width: 490px;margin-bottom: 5px;">
										<select class="part-time-form-elem" name="part_time_day1" xm-select="part_time_day1" xm-select-skin="default">
											<option value="">请选择发送日期</option>
											<option value="1" selected>周一</option>
											<option value="2" selected>周二</option>
											<option value="3" selected>周三</option>
											<option value="4" selected>周四</option>
											<option value="5" selected>周五</option>
											<option value="6" selected>周六</option>
											<option value="0" selected>周日</option>
										</select>
									</div>
									<div class="layui-input-inline" style="margin-bottom: 5px;">
										<input type="text" class="layui-input part-time-form-elem part-time-moment" name="part_time_moment1" id="part_time_moment1" placeholder="开始时间 ~ 结束时间" style="text-align: center;padding-left: 0;">
									</div>

									<div class="public_formTitle_container">
										<lable class="layui-form-label" style="float: none;text-align: left;padding-left: 0;">文字：</lable>
									</div>
									<div class="layui-input-block" style="margin-left: 0;">
										<textarea name="part_time_text1" id="part_time_text1" placeholder="请输入内容"  class="layui-textarea part-time-text part-time-form-elem"></textarea>
									</div>

									<div class="public_formTitle_container">
										<lable class="layui-form-label" style="float: none;text-align: left;padding-left: 0;">其他类型：</lable>
									</div>
									<div class="layui-input-block part-time-otype-radiobox" style="margin-left: 0;margin-bottom: 10px;">
										<input class="part-time-form-elem" type="radio" lay-filter="partTimeOtherType" name="part_time_other_type1" value="1" title="无" checked>
										<input class="part-time-form-elem" type="radio" lay-filter="partTimeOtherType" name="part_time_other_type1" value="2" title="图片">
										<input class="part-time-form-elem" type="radio" lay-filter="partTimeOtherType" name="part_time_other_type1" value="3" title="图文">
										<input class="part-time-form-elem" type="radio" lay-filter="partTimeOtherType" name="part_time_other_type1" value="4" title="小程序">
										<input class="part-time-form-elem" type="radio" lay-filter="partTimeOtherType" name="part_time_other_type1" value="5" title="红包">
									</div>
									<!-- 图片 -->
									<div class="public_form_List part-time-otype-item part_time_otype_img" style="display: none;">
										<div class="public_formTitle_container">
											<lable class="layui-form-label">图片：</lable>
										</div>
										<div class="public_formOther_container">
											<div class="layui-input-block">
												<img onerror="this.style.display='none'" id="preview_part_time_otype_img1" class="part-time-img-preview" src="" style="width: 100px; height: 100px;">
												<input type="hidden" name="part_time_otype_img1" id="part_time_otype_img1" class="part-time-form-elem" />
												<button type="button" class="layui-btn part-time-btn-simg" data-target="part_time_otype_img1" onclick="select_img(this)">
													<i class="layui-icon">&#xe67c;</i>上传图片
												</button>
											</div>
										</div>
									</div>
									<!-- 图文 -->
									<div class="public_form_List part-time-otype-item part_time_otype_imgtext" style="display: none;">
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">标题：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_it_ltitle1" id="part_time_otype_it_ltitle1" required placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">链接：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_it_lurl1" id="part_time_otype_it_lurl1" required placeholder="请输入链接" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">封面：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<img onerror="this.style.display='none'" id="preview_part_time_otype_it_lpic1" class="part-time-img-preview" src="" style="width: 100px; height: 100px;">
													<input type="hidden" name="part_time_otype_it_lpic1" id="part_time_otype_it_lpic1" class="part-time-form-elem" />
													<button type="button" class="layui-btn part-time-btn-simg" onclick="select_img(this)" data-target="part_time_otype_it_lpic1">
														<i class="layui-icon">&#xe67c;</i>上传图片
													</button>
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">描述：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_it_ldesc1" id="part_time_otype_it_ldesc1" required   placeholder="请输入描述" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
									</div>
									<!-- 小程序 -->
									<div class="public_form_List part-time-otype-item part_time_otype_mp" style="display: none;">
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">小程序名称：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_mp_name1" id="part_time_otype_mp_name1" required   placeholder="请输入小程序名称" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">小程序ID：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_mp_appid1" id="part_time_otype_mp_appid1" required   placeholder="请输入ID" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">小程序路径：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_mp_path1" id="part_time_otype_mp_path1" required   placeholder="请输入小程序路径" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">小程序标题：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<input type="text" name="part_time_otype_mp_title1" id="part_time_otype_mp_title1" required   placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elem">
												</div>
											</div>
										</div>
										<div class="public_form_List">
											<div class="public_formTitle_container">
												<lable class="layui-form-label">小程序封面：</lable>
											</div>
											<div class="public_formOther_container">
												<div class="layui-input-block">
													<img onerror="this.style.display='none'" id="preview_part_time_otype_mp_pic1" class="part-time-img-preview" src="" style="width: 100px; height: 100px;">
													<input type="hidden" name="part_time_otype_mp_pic1" id="part_time_otype_mp_pic1" class="part-time-form-elem" />
													<button type="button" class="layui-btn part-time-btn-simg" onclick="select_img(this)" data-target="part_time_otype_mp_pic1">
														<i class="layui-icon">&#xe67c;</i>上传图片
													</button>
												</div>
											</div>
										</div>
									</div>
									<div class="public_form_List part-time-otype-item part_time_otype_red" style="display: none;">
										<div class="public_formTitle_container">
											<lable class="layui-form-label">红包：</lable>
										</div>
										<div class="public_formOther_container">
											<div class="layui-input-block">
												<select name="part_time_otype_red1" id="part_time_otype_red1" class="layui-input part-time-form-elem">
											        <option value="">请根据红包名称选择红包模板</option>
											        {loop $redguest as $redgues}
											        <option value="{$redgues->id}">{$redgues->red_name}</option>
											        {/loop}
											    </select>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>

					</div>

					<!-- 总段数——方便衡量name值的范围，需要的话 -->
					<input type="hidden" id="partTimeCount" name="part_time_count" value="1" />

					<button type="button" class="layui-btn layui-btn-primary part-time-btn-add"
						style="display: none;color: #1E9FFF;margin-left: 92px;border: 0;background: transparent;"
					>
						<i class="layui-icon">&#xe608;</i> 添加分时段欢迎语
					</button>

        </div>

		<div class="public_form_content">
			<div class="public_form_List">
				<div class="public_formTitle_container">
					<lable class="layui-form-label">欢迎语：</lable>
				</div>
				<div class="public_formOther_container">
					<div class="layui-input-block" id="welcome">
					  <input type="checkbox" lay-filter="welcome" name="auto_welcome_msg" lay-skin="switch" checked>
					</div>
				</div>
			</div>
			<div class="public_form_List" id="welcomeContainer">
				<div class="public_formTitle_container">
					<lable class="layui-form-label">文字：</lable>
				</div>
				<div class="public_formOther_container">
					<div class="layui-input-block">
						<div class="insert-btn">
		                 	 <button id="insert" class="layui-btn layui-btn-primary" style="margin-bottom: 5px" type="button" unselectable="on" onmousedown="return false">插入客户名</button>
		                </div>
					  <div contenteditable="true" id="edit_hy_text_content_div" name="edit_hy_text_content_div" class="layui-textarea">{$contactWay->text_content}</div>
					</div>
				</div>
			</div>
		</div>
<div class="public_form_content" id="public_form_contentsss">
	<!-- 时段list -->
	<div class="part-time-lists">
		<!-- 必须 至少有一个 part-time-item，用作添加时的模板。编辑的时候有则带数据循环渲染出来，无则 和首次创建一样渲染个空的 -->
		{if count($welcomeMsg->data) >= 1}
		{loop $welcomeMsg->data as $k=>$data}
		<div class="public_form_List part-time-items" style="position: relative;">
			<div class="public_formTitle_container">
				<lable class="layui-form-label part-time-item-indexs">附件{$k+1}：</lable>
			</div>
			<!-- 删除按钮 -->
			<div class="part-time-item-dels" style="position: absolute;z-index: 9;right: -37px;bottom: 0;">
				<button type="button" class="layui-btn layui-btn-sm layui-btn-primary">
					<i class="layui-icon">&#xe640;</i>
				</button>
			</div>
			<div class="public_formOther_container">
				<div class="layui-input-block" style="padding:10px 20px;background:#fdfdfd;border:1px solid #e5e5e5;">
					<div class="layui-input-block part-time-otype-radiobox" style="margin-left: 0;margin-bottom: 10px;">
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$k+1}" value="1" title="无"  {if $data['type'] == 1}checked {/if}>
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$k+1}" value="2" title="图片" {if $data['type'] == 2}checked {/if}>
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$k+1}" value="3" title="图文" {if $data['type'] == 3}checked {/if}>
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$k+1}" value="4" title="小程序" {if $data['type'] == 4}checked {/if}>
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types{$k+1}" value="5" title="红包" {if $data['type'] == 5}checked {/if}>
					</div>
					<!-- 图片 -->
					<div class="public_form_List part-time-otype-items part_time_otype_imgs" {if $data['type'] != 2}style="display: none;"{/if}>
						<div class="public_formTitle_container">
							<lable class="layui-form-label">图片：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<img onerror="this.style.display='none'" id="preview_part_time_otype_imgs{$k+1}" class="part-time-img-previews" src="{$data['image']}" style="width: 100px; height: 100px;">
								<input type="hidden" name="image{$k+1}" id="part_time_otype_imgs{$k+1}" value="{$data['image']}" class="part-time-form-elems" />
								<button type="button" class="layui-btn part-time-btn-simgs" data-target="part_time_otype_imgs{$k+1}" onclick="select_img(this)">
									<i class="layui-icon">&#xe67c;</i>上传图片
								</button>
							</div>
						</div>
					</div>
					<!-- 图文 -->
					<div class="public_form_List part-time-otype-items part_time_otype_imgtexts" {if $data['type'] != 3}style="display: none;"{/if}>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">标题：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_title{$k+1}" value="{$data['link_title']}" id="part_time_otype_it_ltitles{$k+1}" required placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">链接：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_url{$k+1}"  value="{$data['link_url']}" id="part_time_otype_it_lurls{$k+1}" required placeholder="请输入链接" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">封面：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<img onerror="this.style.display='none'" id="preview_part_time_otype_it_lpics{$k+1}" class="part-time-img-previews" src="{$data['link_pic']}" style="width: 100px; height: 100px;">
									<input type="hidden" value="{$data['link_pic']}" name="link_pic{$k+1}" id="part_time_otype_it_lpics{$k+1}" class="part-time-form-elems" />
									<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_it_lpics{$k+1}">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">描述：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_desc{$k+1}" value="{$data['link_desc']}" id="part_time_otype_it_ldescs{$k+1}" required   placeholder="请输入描述" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
					</div>
					<!-- 小程序 -->
					<div class="public_form_List part-time-otype-items part_time_otype_mps" {if $data['type'] != 4}style="display: none;"{/if}>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序名称：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_name{$k+1}" value="{$data['miniprogram_name']}"  id="part_time_otype_mp_names{$k+1}" required   placeholder="请输入小程序名称" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序ID：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_appid{$k+1}"  value="{$data['miniprogram_appid']}" id="part_time_otype_mp_appids{$k+1}" required   placeholder="请输入ID" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序路径：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_page{$k+1}" value="{$data['miniprogram_page']}" id="part_time_otype_mp_paths{$k+1}" required   placeholder="请输入小程序路径" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序标题：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_title{$k+1}" value="{$data['miniprogram_title']}" id="part_time_otype_mp_titles{$k+1}" required   placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序封面：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<img onerror="this.style.display='none'" id="preview_part_time_otype_mp_pics{$k+1}" class="part-time-img-previews" src="{$data['miniprogram_pic']}" style="width: 100px; height: 100px;">
									<input type="hidden" name="miniprogram_pic{$k+1}" value="{$data['miniprogram_pic']}" id="part_time_otype_mp_pics{$k+1}" class="part-time-form-elems" />
									<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_mp_pics{$k+1}">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
								</div>
							</div>
						</div>
					</div>
					<div class="public_form_List part-time-otype-items part_time_otype_reds" {if $data['type'] != 5}style="display: none;"{/if}>
						<div class="public_formTitle_container">
							<lable class="layui-form-label">红包：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<select name="part_time_otype_reds{$k+1}" id="part_time_otype_reds{$k+1}" class="layui-input part-time-form-elems">
							        {loop $redguest as $redgues}
								        {if $data['red_id'] == $redgues->id}
								        <option value="{$redgues->id}" selected>{$redgues->red_name}</option>
								        {else}
								        <option value="{$redgues->id}">{$redgues->red_name}</option>
								        {/if}
							        {/loop}
							    </select>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		{/loop}
		{else}
		<div class="public_form_List part-time-items" style="position: relative;">
			<div class="public_formTitle_container">
				<lable class="layui-form-label part-time-item-indexs">附件1：</lable>
			</div>
			<!-- 删除按钮 -->
			<div class="part-time-item-dels" style="position: absolute;z-index: 9;right: -37px;bottom: 0;">
				<button type="button" class="layui-btn layui-btn-sm layui-btn-primary">
					<i class="layui-icon">&#xe640;</i>
				</button>
			</div>
			<div class="public_formOther_container">
				<div class="layui-input-block" style="padding:10px 20px;background:#fdfdfd;border:1px solid #e5e5e5;">
					<div class="layui-input-block part-time-otype-radiobox" style="margin-left: 0;margin-bottom: 10px;">
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="1" title="无" checked>
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="2" title="图片">
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="3" title="图文">
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="4" title="小程序">
						<input class="part-time-form-elems" type="radio" lay-filter="partTimeOtherTypes" name="part_time_other_types1" value="5" title="红包">
					</div>
					<!-- 图片 -->
					<div class="public_form_List part-time-otype-items part_time_otype_imgs" style="display: none;">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">图片：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<img onerror="this.style.display='none'" id="preview_part_time_otype_imgs1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
								<input type="hidden" name="image1" id="part_time_otype_imgs1" class="part-time-form-elems" />
								<button type="button" class="layui-btn part-time-btn-simgs" data-target="part_time_otype_imgs1" onclick="select_img(this)">
									<i class="layui-icon">&#xe67c;</i>上传图片
								</button>
							</div>
						</div>
					</div>
					<!-- 图文 -->
					<div class="public_form_List part-time-otype-items part_time_otype_imgtexts" style="display: none;">
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">标题：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_title1" id="part_time_otype_it_ltitles1" required placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">链接：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_url1" id="part_time_otype_it_lurls1" required placeholder="请输入链接" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">封面：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<img onerror="this.style.display='none'" id="preview_part_time_otype_it_lpics1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
									<input type="hidden" name="link_pic1" id="part_time_otype_it_lpics1" class="part-time-form-elems" />
									<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_it_lpics1">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">描述：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="link_desc1" id="part_time_otype_it_ldesc1" required   placeholder="请输入描述" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
					</div>
					<!-- 小程序 -->
					<div class="public_form_List part-time-otype-items part_time_otype_mps" style="display: none;">
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序名称：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_name1" id="part_time_otype_mp_names1" required   placeholder="请输入小程序名称" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序ID：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_appid1" id="part_time_otype_mp_appids1" required   placeholder="请输入ID" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序路径：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_page1" id="part_time_otype_mp_paths1" required   placeholder="请输入小程序路径" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序标题：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<input type="text" name="miniprogram_title1" id="part_time_otype_mp_titles1" required   placeholder="请输入标题" autocomplete="off" class="layui-input part-time-form-elems">
								</div>
							</div>
						</div>
						<div class="public_form_List">
							<div class="public_formTitle_container">
								<lable class="layui-form-label">小程序封面：</lable>
							</div>
							<div class="public_formOther_container">
								<div class="layui-input-block">
									<img onerror="this.style.display='none'" id="preview_part_time_otype_mp_pics1" class="part-time-img-previews" src="" style="width: 100px; height: 100px;">
									<input type="hidden" name="miniprogram_pic1" id="part_time_otype_mp_pics1" class="part-time-form-elems" />
									<button type="button" class="layui-btn part-time-btn-simgs" onclick="select_img(this)" data-target="part_time_otype_mp_pics1">
										<i class="layui-icon">&#xe67c;</i>上传图片
									</button>
								</div>
							</div>
						</div>
					</div>
					<div class="public_form_List part-time-otype-items part_time_otype_reds" style="display: none;">
						<div class="public_formTitle_container">
							<lable class="layui-form-label">红包：</lable>
						</div>
						<div class="public_formOther_container">
							<div class="layui-input-block">
								<select name="part_time_otype_reds1" id="part_time_otype_reds1" class="layui-input part-time-form-elems">
							        <option value="">请根据红包名称选择红包模板</option>
							        {loop $redguest as $redgues}
							        <option value="{$redgues->id}">{$redgues->red_name}</option>
							        {/loop}
							    </select>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		{/if}
	</div>
	<input type="hidden" id="partTimeCounts" name="part_time_counts" value="{count($welcomeMsg->data)?count($welcomeMsg->data):1}" />
	<input type="hidden" id="text_content" name="text_content" />
	<button type="button" class="layui-btn layui-btn-primary part-time-btn-adds"style="color: #1E9FFF;margin-left: 92px;border: 0;background: transparent;"><i class="layui-icon">&#xe608;</i> 添加附件
	</button>
 </div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						<!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
					</div>
				</div>
			</div>
			<!-- 公共表单部分 end-->
		</div>
	</form>
	<script src="/cdn/jquery.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/cusmanage/js/formSelects-v4.min.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
	// 添加时间段
	function addOnePartTimes() {
		var $items = $('.part-time-lists .part-time-items')
		var length = $items.length
		if($('.part-time-lists .part-time-items').length >= 9){
			alert("最多只能有九个附件");
			return false;
		}
		var tpl = $items.eq(0).clone(false)
			setPartTimeItemIds(tpl, length + 1, true)
			$(".part-time-lists").append(tpl)
			layui.form.render()
			layui.laydate.render({
				elem: '#part_time_moment' + (length + 1)
				,type: 'time'
				,range: '~'
				,format: 'HH:mm'
			})
			setCounts(length + 1)

	}
	function setPartTimeItemIds($item, index, clear) {
		$item.find('.part-time-item-indexs').text('附件' + index + '：')
		var $inputs = $item.find('.part-time-form-elems')
		for (var i = 0, l = $inputs.length; i < l; i++) {
			var $theInput = $($inputs[i])
			if (clear && $theInput.attr('type') !== 'radio') {
				$theInput.val('')
			}
			setElemAttrs($theInput, index)
		}
		var $prevImgs = $item.find('.part-time-img-previews')
		for (var i = 0, l = $prevImgs.length; i < l; i++) {
			setElemAttrs($($prevImgs[i]), index)
		}
		var $sImgBtns = $item.find('.part-time-btn-simgs')
		for (var i = 0, l = $sImgBtns.length; i < l; i++) {
			setElemAttrs($($sImgBtns[i]), index)
		}
		return $item
	}
	function setElemAttrs($elem, index) {
		var id = $elem.attr('id'), name = $elem.attr('name'), _name = $elem.attr('_name'), dataTarget = $elem.attr('data-target'), layKey = $elem.attr('lay-key'), xmSelect = $elem.attr('xm-select');
		var reg = /([0-9]+)/g
		$elem.attr({
			id: id && (id.replace(reg, '') + index),
			name: name && (name.replace(reg, '') + index),
			'data-target': dataTarget && (dataTarget.replace(reg, '') + index), // 上传图片按钮
			'_name': _name && (_name.replace(reg, '') + index), // 日期多选
			'xm-select': xmSelect && (xmSelect.replace(reg, '') + index), // 日期多选
			'lay-key': layKey ? (String(index) + Date.now()) : layKey, // 时间选择器
		});
	}
	// 添加时间段按钮
	$('.part-time-btn-adds').on('click', addOnePartTimes)
	// 删除时间段
	$('.part-time-lists').on('click', '.part-time-item-dels', function() {
		if ($('.part-time-lists .part-time-items').length <= 1) {
			alert('不能再少了')
		} else {
			$(this).parent().remove()
			updateItemsOrders()
		}
	})
	function updateItemsOrders() {
		var $items = $('.part-time-lists .part-time-items')
		var l = $items.length
		setCounts(l)
		for (var i = 0; i < l; i++) {
			var $theItem = $($items[i])
			setPartTimeItemIds($theItem, i + 1, false)
		}
		layui.form.render()
	}

	function setCounts(n) {
		if (n === undefined) {
			n = $('.part-time-lists .part-time-items').length
		}
		$('#partTimeCounts').val(n)
	}

	layui.use('form', function(){
		var form = layui.form;
	  // 其他类型 切换
	  form.on('radio(partTimeOtherTypes)', function (data) {
			var $itemWrap = $(this).parents('.part-time-items')
			var val = $itemWrap.find('input[lay-filter="partTimeOtherTypes"]:checked').val()

			$itemWrap.find('.part-time-otype-items').hide()
			$itemWrap.find('.part-time-form-elems').removeAttr("lay-verify");

			var theTypeBoxClass = null
			if (val == 2) {
				theTypeBoxClass = '.part_time_otype_imgs'
			} else if (val == 3) {
				theTypeBoxClass = '.part_time_otype_imgtexts'
			} else if (val == 4) {
				theTypeBoxClass = '.part_time_otype_mps'
			}else if (val == 5) {
				theTypeBoxClass = '.part_time_otype_reds'
			}
			if (theTypeBoxClass) {
				var $theTypeBox = $itemWrap.find(theTypeBoxClass)
				$theTypeBox.find('.part-time-form-elems').attr("lay-verify","required");
				$theTypeBox.show()
			}
			form.render();
		});
	});
</script>
	<script>
		// 添加二维码图片
		layui.use('upload', function(){
		  var $ = layui.jquery
		  ,upload = layui.upload;
		});
		 function falses() {
	        $("#filkes").trigger("click");
	        openuploadstow();
	    }
    
        function openuploadstow() {
	        $("#filkes").change(function () {
	            var formdata = new FormData();
	            formdata.append('file', $("#filkes")[0].files[0]); //获取file信息
	            console.log(formdata);
	            $.ajax({
	                url: "add_file.html",
	                type: 'post',
	                data: formdata,
	                cache: false,
	                dataType: 'json',
	                processData: false,
	                contentType: false,
	                success: function (e) {
	                    if (e.status == "success") {
	                		layer.msg(e.msg);
	                        var data = e.data.filePath;
	                        $('#demo1').attr('src', data);
	                        $("#imghiden").val(data);
	                    } else {
	                        layer.msg(e.msg, '');
	                    }
	                }
	            });
	        });
	    }

		// 添加时间段
		function addOnePartTime() {
			var $items = $('.part-time-list .part-time-item')
			var length = $items.length
			if (!length) {
				return console.error('至少要有一个 .part-time-item 用作模板')
			}
			var tpl = $items.eq(0).clone(false)
			setPartTimeItemId(tpl, length + 1, true)
			$(".part-time-list").append(tpl)
			layui.formSelects.render('part_time_day' + (length + 1));
			layui.form.render()
			setCount(length + 1)
			initTimeSelects();
			// console.log('formData: ', $('#form1').serialize())
			// console.log('formData: ', $('#form1').serializeArray())
		}
		function setPartTimeItemId($item, index, clear) {
			$item.find('.part-time-item-index').text('时段' + index + '：')
			var $inputs = $item.find('.part-time-form-elem')
			for (var i = 0, l = $inputs.length; i < l; i++) {
				var $theInput = $($inputs[i])
				if (clear && $theInput.attr('type') !== 'radio') {
					$theInput.val('')
				}
				setElemAttr($theInput, index)
			}
			var $prevImgs = $item.find('.part-time-img-preview')
			for (var i = 0, l = $prevImgs.length; i < l; i++) {
				setElemAttr($($prevImgs[i]), index)
			}
			var $sImgBtns = $item.find('.part-time-btn-simg')
			for (var i = 0, l = $sImgBtns.length; i < l; i++) {
				setElemAttr($($sImgBtns[i]), index)
			}
			return $item
		}
		function setElemAttr($elem, index) {
			var id = $elem.attr('id'), name = $elem.attr('name'), _name = $elem.attr('_name'), dataTarget = $elem.attr('data-target'), layKey = $elem.attr('lay-key'), xmSelect = $elem.attr('xm-select');
			var reg = /([0-9]+)/g
			$elem.attr({
				id: id && (id.replace(reg, '') + index),
				name: name && (name.replace(reg, '') + index),
				'data-target': dataTarget && (dataTarget.replace(reg, '') + index), // 上传图片按钮
				'_name': _name && (_name.replace(reg, '') + index), // 日期多选
				'xm-select': xmSelect && (xmSelect.replace(reg, '') + index), // 日期多选
				'lay-key': layKey ? (String(index) + Date.now()) : layKey, // 时间选择器
			});
		}
		// 添加时间段按钮
		$('.part-time-btn-add').on('click', addOnePartTime)
		// 删除时间段
		$('.part-time-list').on('click', '.part-time-item-del', function() {
			if ($('.part-time-list .part-time-item').length <= 1) {
				alert('不能再少了')
			} else {
				$(this).parent().remove()
				updateItemsOrder()
			}
		})
		function updateItemsOrder() {
			var $items = $('.part-time-list .part-time-item')
			var l = $items.length
			setCount(l)
			for (var i = 0; i < l; i++) {
				var $theItem = $($items[i])
				setPartTimeItemId($theItem, i + 1, false)
				// 更新多选框
				var theMultiSelectsVal = $theItem.find('.xm-hide-input').val()
				layui.formSelects.render('part_time_day' + (i + 1),
					theMultiSelectsVal ? { init: theMultiSelectsVal.split(',') } : undefined
				);
			}
			layui.form.render()
			initTimeSelects()
		}
		// 初始化、重新渲染 事件选择器
		function initTimeSelects() {
			lay('.part-time-list .part-time-moment').each(function() {
				layui.laydate.render({
					elem: this
					,type: 'time'
					,range: '~'
					,format: 'HH:mm'
				})
			})
		}
		function setCount(n) {
			if (n === undefined) {
				n = $('.part-time-list .part-time-item').length
			}
			$('#partTimeCount').val(n)
		}

		layui.use('laydate', initTimeSelects)

		layui.use('form', function(){
			var form = layui.form;
			// 欢迎语 开关切换
		  form.on('switch(partTimeWelcome)', function(data){
				if(data.elem.checked){
			    $('.part-time-list .part-time-form-elem').attr("lay-verify","required");
			    // $('.xm-hide-input').attr("lay-verify","required"); // 日期多选
					$(".part-time-list").show();
					$('.part-time-btn-add').show()
					$('.part-time-list .part-time-otype-radiobox .part-time-form-elem:checked').next('.layui-form-radio').click()
		    } else {
					$(".part-time-list").hide();
					$('.part-time-btn-add').hide()
					$('.part-time-list .part-time-form-elem').removeAttr("lay-verify");
				}
				form.render();
			});
		  // 其他类型 切换
		  form.on('radio(partTimeOtherType)', function (data) {
				var $itemWrap = $(this).parents('.part-time-item')
				var val = $itemWrap.find('input[lay-filter="partTimeOtherType"]:checked').val()
 
				$itemWrap.find('.part-time-otype-item').hide()
				$itemWrap.find('.part-time-form-elem').removeAttr("lay-verify");

				var theTypeBoxClass = null
				if (val == 1) {
					$itemWrap.find('.part-time-text').attr("lay-verify","required");
				} else {
					$itemWrap.find('.part-time-text').removeAttr("lay-verify");
				}
				if (val == 2) {
					theTypeBoxClass = '.part_time_otype_img'
				} else if (val == 3) {
					theTypeBoxClass = '.part_time_otype_imgtext'
				} else if (val == 4) {
					theTypeBoxClass = '.part_time_otype_mp'
				}else if (val == 5) {
					theTypeBoxClass = '.part_time_otype_red'
				}
				if (theTypeBoxClass) {
					var $theTypeBox = $itemWrap.find(theTypeBoxClass)
					$theTypeBox.find('.part-time-form-elem').attr("lay-verify","required");
					$theTypeBox.show()
				}

				form.render();
			});
		});
	</script>
	<script type="text/javascript">
		layui.use('layer', function(){
		  var layer = layui.layer;
		}); 
		layui.use('form', function(){
		  var form = layui.form;
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    edit_hy_text_content_div = $("#edit_hy_text_content_div").html();
		    $("#text_content").val(edit_hy_text_content_div);
			var formData = $('#form1').serialize();	
			myAjaxPost(false, true, 'add_contact_way.html', formData, function (resp) {
				console.log(resp);
				if (resp.status == 'success') {
					tusi(resp.msg);
					setTimeout(function(){
						location.href = 'contact_way.html'; 
					},2000);
				}else{
					alert(resp.msg);
				}
			});
		  });
		  // 其他类型
		  form.on('radio(shareType)', function (data) {
                if ($('#shareType input[name="shareType"]:checked').val() == "1") {
					$('#image').removeAttr("lay-verify");
					$('#link_title').removeAttr("lay-verify");
					$('#link_url').removeAttr("lay-verify");
					$('#miniprogram_appid').removeAttr("lay-verify");
					$('#miniprogram_title').removeAttr("lay-verify");
					$('#miniprogram_pic').removeAttr("lay-verify");
					$('#text_content').attr("lay-verify","required");
                    $(".publicHide_content").hide();
                }else if($('#shareType input[name="shareType"]:checked').val() == "2"){
					$('#text_content').removeAttr("lay-verify");
					$('#link_title').removeAttr("lay-verify");
					$('#link_url').removeAttr("lay-verify");
					$('#miniprogram_appid').removeAttr("lay-verify");
					$('#miniprogram_title').removeAttr("lay-verify");
					$('#miniprogram_pic').removeAttr("lay-verify");
					$('#image').attr("lay-verify","required");
                	$(".publicHide_content").hide();
                	$("#imgcontainer").show();
                }else if($('#shareType input[name="shareType"]:checked').val() == "3"){
					$('#text_content').removeAttr("lay-verify");
					$('#image').removeAttr("lay-verify");
					$('#miniprogram_appid').removeAttr("lay-verify");
					$('#miniprogram_title').removeAttr("lay-verify");
					$('#miniprogram_pic').removeAttr("lay-verify");
					$('#link_title').attr("lay-verify","required");
					$('#link_url').attr("lay-verify","required");
                	$(".publicHide_content").hide();
                	$("#imgtextcontainer").show();
                }else if($('#shareType input[name="shareType"]:checked').val() == "4"){
					$('#text_content').removeAttr("lay-verify");
					$('#image').removeAttr("lay-verify");
					$('#link_title').removeAttr("lay-verify");
					$('#link_url').removeAttr("lay-verify");
					$('#miniprogram_appid').attr("lay-verify","required");
					$('#miniprogram_title').attr("lay-verify","required");
					$('#miniprogram_pic').attr("lay-verify","required");
                	$(".publicHide_content").hide();
                	$("#xcxcontainer").show();
                }else if($('#shareType input[name="shareType"]:checked').val() == "5"){
					$('#text_content').removeAttr("lay-verify");
					$('#image').removeAttr("lay-verify");
					$('#link_title').removeAttr("lay-verify");
					$('#link_url').removeAttr("lay-verify");
					$('#miniprogram_appid').removeAttr("lay-verify");
					$('#miniprogram_title').removeAttr("lay-verify");
					$('#miniprogram_pic').removeAttr("lay-verify");
					$('#interest').attr("lay-verify","required");
                	$(".publicHide_content").hide();
                	$("#hongbao").show();
                }
                
                form.render();
            });
		  // 自动标签
		  form.on('switch(autoLable)', function(data){
		      console.log(data.elem.checked); //是否被选中，true或者false
		      if(data.elem.checked == true){
		      	$("#autoLableContainer").show();
		      }else{
		      	$("#autoLableContainer").hide();
		      }
		      form.render();
		  });

		  // 发放优惠券
		  form.on('switch(pb_coupon)', function(data){
		      if(data.elem.checked == true){
		      	$(".pb_coupon").show();
		      }else{
		      	$(".pb_coupon").hide();
		      }
		      form.render();
		  });
		  // 设置等级
		  form.on('switch(pb_setlevel)', function(data){
		      if(data.elem.checked == true){
		      	$(".pb_setlevel").show();
		      }else{
		      	$(".pb_setlevel").hide();
		      }
		      form.render();
		  });

		  // 欢迎语
		  form.on('switch(welcome)', function(data){
		      if(data.elem.checked == true){
		      	$("#welcomeContainer").show();
		      	$("#public_form_contentsss").show();
		      	$("#otherType").show();
		      }else{
				$('#image').removeAttr("lay-verify");
				$('#link_title').removeAttr("lay-verify");
				$('#link_url').removeAttr("lay-verify");
				$('#miniprogram_appid').removeAttr("lay-verify");
				$('#miniprogram_title').removeAttr("lay-verify");
				$('#miniprogram_pic').removeAttr("lay-verify");
		      	$("#public_form_contentsss").hide();
		      	$("#welcomeContainer").hide();
		      	$("#otherType").hide();
		      }
		      form.render();
		  });
		});
	</script>
	<script type="text/javascript">
		$('#addPeople').on('click',function(){
			layer.open({
			  type: 2,
			  title: '请选择使用人员',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['700px', '530px'],
			  content: 'select_user.html'
			}); 
		})
		$('#addLable').on('click',function(){
			layer.open({
			  type: 2,
			  title: '请选择标签',
			  shadeClose: true,
			  shade: 0.2,
			  area: ['700px', '530px'],
			  content: 'select_tag.html'
			}); 
		})
	</script>
	<script>
	layui.use(['element', 'layer', 'upload'], function () {
	  var layer = layui.layer;
	});
	function select_img(a){
	  var targetId=a.getAttribute('data-target');
	  layer.open({
		title:'图片库',
		type: 2,
		area: ['700px', '450px'],
		fixed: false, //不固定
		maxmin: false,
		content: '/imgLib/lib.html?type=vshop_img&target='+targetId
	  });
	}

	window.uploadImgCallback=function (tgt,url) {
	  console.log('选择图片结果',tgt,url);
	  if(tgt=='image'){
		var inputEle=$('#image');
		var prevEle=$('#pic_image');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt=='link_pic'){
		var inputEle=$('#link_pic');
		var prevEle=$('#pic_link_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt=='miniprogram_pic'){
		var inputEle=$('#miniprogram_pic');
		var prevEle=$('#pic_miniprogram_pic');
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }else if(tgt.indexOf('part_time_') > -1){ // 分时段 通用
		var inputEle=$('#' + tgt);
		var prevEle=$('#preview_' + tgt);
		inputEle.val(url);
		prevEle.attr('src',url);
		prevEle.show();
	  }
	};
	</script>
	<script type="text/javascript">
		
	// 在光标位置插入html代码，如果dom没有获取到焦点则追加到最后
     window.onload= function(){
            function insertAtCursor(jsDom, html) {
            if (jsDom != document.activeElement) { // 如果dom没有获取到焦点，追加
                jsDom.innerHTML = jsDom.innerHTML + html;
                return;
            }
            var sel, range;
            if (window.getSelection) {
                // IE9 或 非IE浏览器
                debugger
                sel = window.getSelection();
                if (sel.getRangeAt && sel.rangeCount) {
                    range = sel.getRangeAt(0);
                    range.deleteContents();
                    // Range.createContextualFragment() would be useful here but is
                    // non-standard and not supported in all browsers (IE9, for one)
                    var el = document.createElement("div");
                    el.innerHTML = html;
                    var frag = document.createDocumentFragment(),
                        node, lastNode;
                    while ((node = el.firstChild)) {
                        lastNode = frag.appendChild(node);
                    }
                    range.insertNode(frag);
                    // Preserve the selection
                    if (lastNode) {
                        range = range.cloneRange();
                        range.setStartAfter(lastNode);
                        range.collapse(true);
                        sel.removeAllRanges();
                        sel.addRange(range);
                    }
                }
            } else if (document.selection && document.selection.type != "Control") {
                // IE < 9
                document.selection.createRange().pasteHTML(html);
            }
        }
 
        //  点击插入
       document.getElementById('insert').onclick = function() {
            var html = '<font style="color: green;">用户昵称</font>&nbsp;';
            insertAtCursor(document.getElementById('edit_hy_text_content_div'), html);
        };
    }
	</script>
</body>
</html>